<?php

namespace JLPay\Models\Ledger\Merchconf;

use JLPay\Models\BaseRequest;

/**
 * 商户分账发行更新请求
 */
class MerchIssueUpdateRequest extends BaseRequest
{
    /**
     * API URL
     */
    public const API_URL = '/open/ledger/merch/issue/update';

    protected ?string $orgCode = null;
    protected ?string $mchId = null;
    protected ?string $ledgerModule = null;
    protected ?string $maxSplitRate = null;
    protected ?array $sourceIds = null;
    protected ?string $feeRate = null;
    protected ?string $pbthf = null;
    protected ?string $lowAmt = null;
    protected ?string $upAmt = null;
    protected ?string $notifyUrl = null;

    /**
     * 设置机构代码
     *
     * @param string $orgCode
     * @return self
     */
    public function setOrgCode(string $orgCode): self
    {
        $this->orgCode = $orgCode;
        return $this;
    }

    /**
     * 设置商户号
     *
     * @param string $mchId
     * @return self
     */
    public function setMchId(string $mchId): self
    {
        $this->mchId = $mchId;
        return $this;
    }

    /**
     * 设置账本模块
     *
     * @param string $ledgerModule
     * @return self
     */
    public function setLedgerModule(string $ledgerModule): self
    {
        $this->ledgerModule = $ledgerModule;
        return $this;
    }

    /**
     * 设置最大分账比例
     *
     * @param string $maxSplitRate
     * @return self
     */
    public function setMaxSplitRate(string $maxSplitRate): self
    {
        $this->maxSplitRate = $maxSplitRate;
        return $this;
    }

    /**
     * 设置来源ID列表
     *
     * @param array $sourceIds
     * @return self
     */
    public function setSourceIds(array $sourceIds): self
    {
        $this->sourceIds = $sourceIds;
        return $this;
    }

    /**
     * 设置费率
     *
     * @param string $feeRate
     * @return self
     */
    public function setFeeRate(string $feeRate): self
    {
        $this->feeRate = $feeRate;
        return $this;
    }

    /**
     * 设置保底后收费
     *
     * @param string $pbthf
     * @return self
     */
    public function setPbthf(string $pbthf): self
    {
        $this->pbthf = $pbthf;
        return $this;
    }

    /**
     * 设置最低金额
     *
     * @param string $lowAmt
     * @return self
     */
    public function setLowAmt(string $lowAmt): self
    {
        $this->lowAmt = $lowAmt;
        return $this;
    }

    /**
     * 设置最高金额
     *
     * @param string $upAmt
     * @return self
     */
    public function setUpAmt(string $upAmt): self
    {
        $this->upAmt = $upAmt;
        return $this;
    }

    /**
     * 设置通知URL
     *
     * @param string $notifyUrl
     * @return self
     */
    public function setNotifyUrl(string $notifyUrl): self
    {
        $this->notifyUrl = $notifyUrl;
        return $this;
    }

    /**
     * 转换为数组
     *
     * @return array
     */
    public function toArray(): array
    {
        $data = parent::toArray();
        
        // 确保sourceIds作为数组传递
        if ($this->sourceIds !== null) {
            $data['source_ids'] = $this->sourceIds;
        }
        
        return $data;
    }

    /**
     * 获取机构代码
     *
     * @return string|null
     */
    public function getOrgCode(): ?string
    {
        return $this->orgCode;
    }

    /**
     * 获取商户号
     *
     * @return string|null
     */
    public function getMchId(): ?string
    {
        return $this->mchId;
    }

    /**
     * 获取账本模块
     *
     * @return string|null
     */
    public function getLedgerModule(): ?string
    {
        return $this->ledgerModule;
    }

    /**
     * 获取最大分账比例
     *
     * @return string|null
     */
    public function getMaxSplitRate(): ?string
    {
        return $this->maxSplitRate;
    }

    /**
     * 获取来源ID列表
     *
     * @return array|null
     */
    public function getSourceIds(): ?array
    {
        return $this->sourceIds;
    }

    /**
     * 获取费率
     *
     * @return string|null
     */
    public function getFeeRate(): ?string
    {
        return $this->feeRate;
    }

    /**
     * 获取保底后收费
     *
     * @return string|null
     */
    public function getPbthf(): ?string
    {
        return $this->pbthf;
    }

    /**
     * 获取最低金额
     *
     * @return string|null
     */
    public function getLowAmt(): ?string
    {
        return $this->lowAmt;
    }

    /**
     * 获取最高金额
     *
     * @return string|null
     */
    public function getUpAmt(): ?string
    {
        return $this->upAmt;
    }

    /**
     * 获取通知URL
     *
     * @return string|null
     */
    public function getNotifyUrl(): ?string
    {
        return $this->notifyUrl;
    }
} 